package com.ayoka.ui.mine.purchase_record;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.View;

import com.ayoka.R;
import com.ayoka.adapter.PurchaseRecordAdapter;
import com.ayoka.base.BaseRecyclerViewActivity;
import com.ayoka.databinding.ActivityBaseRecyclerviewBinding;
import com.ayoka.mvp.PurchaseRecordMVP.PurchaseRecordModel.PurchaseRecordBean;
import com.ayoka.mvp.PurchaseRecordMVP.PurchaseRecordPresenter;
import com.ayoka.mvp.PurchaseRecordMVP.IPurchaseRecordView;
import com.jcp.baselibrary.brvah.BaseQuickAdapter;
import com.jcp.baselibrary.brvah.BaseViewHolder;
import com.jcp.baselibrary.brvah.RecycleViewDivider;
import com.jcp.baselibrary.model.ToolBarOptions;
import com.jcp.baselibrary.utils.UIUtils;

import java.util.List;


/**
 * @author jcp
 * @ClassName: TopicListActivity
 * @Description:
 * @date 2018-12-28 下午4:21:18
 */
public class PurchaseRecordActivity extends BaseRecyclerViewActivity<PurchaseRecordBean, ActivityBaseRecyclerviewBinding, PurchaseRecordPresenter> implements IPurchaseRecordView {

    public static void start(Activity activity) {
        Intent intent = new Intent(activity, PurchaseRecordActivity.class);
        activity.startActivity(intent);
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_base_recyclerview;
    }

    @Override
    protected SwipeRefreshLayout getRefreshLayout() {
        return mDataBinding.swipeRefresh ;
    }

    @Override
    protected RecyclerView getRecyclerView() {
        mDataBinding.recyclerView.setBackgroundResource(R.color.white_f2);
        return mDataBinding.recyclerView;
    }

    @Override
    protected BaseQuickAdapter<PurchaseRecordBean, BaseViewHolder> getAdapter() {
        PurchaseRecordAdapter adapter = new PurchaseRecordAdapter();
        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                PurchaseRecordBean item = (PurchaseRecordBean) adapter.getItem(position);
            }
        });
        return adapter;
    }

    @Override
    protected RecyclerView.ItemDecoration getRecycleDivider() {
        return new RecycleViewDivider.Builder(this)
                .setStyle(RecycleViewDivider.Style.BOTH)
                .setColor(Color.TRANSPARENT)
                .setSize(TypedValue.COMPLEX_UNIT_PX, UIUtils.getDimensionPixelSize(R.dimen.dp_15))
                .build();
    }

    @Override
    protected void getData(boolean isShowWaitDialog) {
        mPresenter.getPurchaseRecordListData(isShowWaitDialog);
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        ToolBarOptions options = new ToolBarOptions(R.string.purchase_record);
        setCustomToolBar(mDataBinding.customToolbar.toolbar, options);

        getData(true);
    }

    @Override
    protected PurchaseRecordPresenter getPresenter() {
        return new PurchaseRecordPresenter();
    }

    @Override
    public void configPurchaseRecordListData(List<PurchaseRecordBean> listData) {
        setLoadMoreLayout(listData);
    }
}
